package com.view.componet;

import java.util.Iterator;
import com.controller.UsuarioController;
import com.model.Usuario;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.HorizontalSplitPanel;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeButton;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Button.ClickEvent;
import com.view.LoginView;


/**
 * Classe gera o menu lateral
 * @author Ricardo
 *
 */
public class Menu extends HorizontalSplitPanel implements ClickListener{
	
	public Menu(){
		
		    //estilo e posi�‹o da barra!
	        addStyleName("small blue white");
	        setSplitPosition(16);
	        setWidth("100%");
	        setHeight("100%");
	        setMargin(true);
		        
	        //Define CSS
	        CssLayout menu = new CssLayout();
	        menu.addStyleName("menu");
	        menu.setWidth("100%");
	        setFirstComponent(menu);
    
	        //Adiciona primeira categoria Auditor 
	        Label l = new Label("Funcionalidades");
	        l.addStyleName("section");
	        menu.addComponent(l);

	        //Itens da categoria auditor
	        
	         
	        //Cria o bot‹o e define estilo
	        NativeButton b = new NativeButton("Usuario");
	        b.setHeight("30px");
	        b.addStyleName("selected");
	        b.addListener(this);
	        menu.addComponent(b);
	        
	        //Cria um layout para receber o organiza�‹o view
	        AbsoluteLayout verticalLayoutMenu = new AbsoluteLayout();
	    	verticalLayoutMenu.setHeight("100.0%");
	    	verticalLayoutMenu.setWidth("100.0%");
	    	
	    	//LoginView ll = new LoginView();
	    	
	    	//verticalLayoutMenu.addComponent(ll, "top:0.0px;left:0.0px;");
	        b.setData(verticalLayoutMenu);
	        
	 
	}
	
		//Eventos para tratar a sele�‹o entre os itens
	      public void buttonClick(ClickEvent event) {
                ComponentContainer p = (ComponentContainer) event.getButton()
                        .getParent();
                for (Iterator iterator = p.getComponentIterator(); iterator
                        .hasNext();) {
                    ((AbstractComponent) iterator.next())
                            .removeStyleName("selected");
                }
                event.getButton().addStyleName("selected");
                setSecondComponent((Component) event.getButton()
                        .getData());
            }
        	
}
